package org.example.AI;


import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Learn Java from https://www.liaoxuefeng.com/
 *
 * @author liaoxuefeng
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        BotContext bot = new BotContext();
        Random random = new Random();
        ExecutorService executor = Executors.newSingleThreadExecutor();

        for (; ; ) {
            System.out.print("> ");
            String input = scanner.nextLine();
            String output = bot.chat(input);
            System.out.println(output.isEmpty() ? "(no reply)" : "< " + output);

            // 每隔一段时间，随机触发一个长时间运行的任务
            if (random.nextInt(5) == 0) {
                // executor.submit(() -> bot.simulateLongRunningTask());
                bot.startTask();
            }

            if (random.nextInt(5) == 1) {
                // executor.submit(() -> bot.simulateLongRunningTask());
                bot.endTask();
            }

        }

    }

}

